# -*- encoding: utf-8 -*-


def quick_sort(collection):
    # 递归终止条件
    if len(collection) <= 1:
        return collection

    pivot = collection.pop()
    lesser, greater = [], []
    for i in collection:
        if i < pivot:
            lesser.append(i)
        if i > pivot:
            greater.append(i)
    # 递归公式
    return quick_sort(lesser) + [pivot] + quick_sort(greater)


if __name__ == '__main__':
    print(quick_sort([9, 1, 2, 6, 8, 3, 7, 6, 5, 0]))
